/*
 * Kpatch module
 *
 * The core code comes from tpatch, the early hot patch tool of tlinux.
 *
 */
#ifndef _TPATCH_H
#define _TPATCH_H

#include <linux/types.h>
#include <linux/percpu_counter.h>
#include "hook_tk5.h"

struct verify_func
{
	char *modname;
	struct module *mod;
	char *name;
	unsigned long old_addr;
	unsigned long old_offset;
	unsigned long new_addr;
	unsigned long new_offset;
};

extern int system_hook_name;
extern struct percpu_counter patch_num;
extern struct percpu_counter patch_num_system;

static inline void enter_hook(void)
{
	percpu_counter_inc(&patch_num);
}

static inline void exit_hook(void)
{
	percpu_counter_dec(&patch_num);
}
static inline void enter_hook_system(void)
{
	percpu_counter_inc(&patch_num_system);
}

static inline void exit_hook_system(void)
{
	percpu_counter_dec(&patch_num_system);
}

extern int system_base_function_hook(void);
extern int system_base_function_unhook(void);

extern int patch_init(void);
extern void patch_exit(void);

#endif
